package ua.net.gm.common.entity;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Yason
 */
public class EntityDictCatalog
{
    private final Map<EntityType, IEntityDict> dict;
    
    public EntityDictCatalog()
    {
        dict = new HashMap<>();
    }
    
    public IEntityDict getDict(EntityType type)
    {
        return dict.get(type);
    }
    
    public IEntityDict getDict(String type)
    {
        return dict.get(new EntityType(type));
    }
    
    void createDict(EntityType type, IEntityDictFactory factory, EntitySupport entitySupport)
    {
        IEntityDict res = dict.get(type);
        if (res == null)
        {
            res = factory.create(entitySupport, type);
            dict.put(type, res);
        }  
    }
}
